/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.pkw.common;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Agnieszka
 */
@XmlRootElement()
public class VotingData 
{
    private Integer sId = 10;
    
    private String name = "ddda";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    private List<Card>cards=new LinkedList<Card>();
    
    private Card skipCard;

    public List<Card> getCards() {
        return cards;
    }

    public void setCards(List<Card> cards) {
        this.cards = cards;
    }

    public Integer getsId() {
        return sId;
    }

    public void setsId(Integer sId) {
        this.sId = sId;
    }

 

    public Card getSkipCard() {
        return skipCard;
    }

    public void setSkipCard(Card skipCard) {
        this.skipCard = skipCard;
    }
    
    /**
     * 
     * 
     * @param card - template card
     * @param number - number of generated card
     */
    public void generate(SecureRandom random, Card card, Integer number) throws UnsupportedEncodingException
    {
        for(int i=0; i<number; i++)
        {
            Card c = card.clone();
            c.setNumber(i+1);
            BigInteger serial  = Tool.nextSerialNumber(random);
            for(Vote v: c.getVotes())
            {
                v.setVoteCard(serial);
                v.calculateHashVote();
            }            
            getCards().add(c);
        }
    }

    
}
